#include "head.h"
#include "key.h"
#include "smg.h"
#include "iic.h"
#include "at24c02_eeprom.h"

#define at24c02_address	0

int main()
{
	u8 kk=0;
	u8 buf1[3];
	u8 datt=0;
	while(1)
	{
		kk=key_scan(0);
		if(kk==KEY1_PRESS)
		{
			at24c02_write_onebyte(at24c02_address,datt);	
		}
		else if(kk==KEY2_PRESS)	
		{
			datt=at24c02_read_onebyte(at24c02_address);
		}
		else if(kk==KEY3_PRESS)
		{
			datt++;
			if(datt>=255)
			{
				datt=255;
			}
		}
		else if(kk==KEY4_PRESS)
		{
			datt=0;
		}
		buf1[0]=datt/100;
		buf1[1]=(datt/10)%10;
		buf1[2]=datt%100%10;
		smg_display(buf1,6);
	}
	return 0;
}